﻿using KendoUIGridSignalR.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace KendoUIGridSignalR.Code
{
    public static class GetStockData
    {
        // Author: Otto Neff | webapps-in-action.com
        public static StockData GetData(string stockName)
        {
            StockData s = new StockData();
            Random rnd = new Random();
            s.LastChange = DateTime.Now;
            s.Price = (decimal)(rnd.Next(1, 500) * rnd.NextDouble());
            switch (rnd.Next(1, 4))            {
                case 1:
                    s.Name = "A";
                    break;
                case 2:
                    s.Name = "B";
                    break;
                default:
                    s.Name = "C";
                    break;
            }
            if(!string.IsNullOrEmpty(stockName))
            {
                s.Name = stockName;
            }
            return s;
        }
    }
}